package com.Cfeng.XiaohuanChat.controller;

import com.Cfeng.XiaohuanChat.domain.Resp;
import com.Cfeng.XiaohuanChat.entity.ChatUserAuthority;
import com.Cfeng.XiaohuanChat.service.ChatAuthorityService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Cfeng
 * @date 2022/8/7
 */

@RestController
@RequiredArgsConstructor
@RequestMapping("/authority")
public class ChatAuthorityController {

    private final ChatAuthorityService authorityService;

    @PostMapping("/addAuthority")
    public Resp<ChatUserAuthority> addAuthority(@Validated @RequestBody ChatUserAuthority userAuthority) {
        ChatUserAuthority authority = authorityService.addAuthority(userAuthority);
        return Resp.ok(authority);
    }
}
